package com.weiyuwqj.admin.controller.admin.asset;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.weiyuwqj.admin.controller.base.BaseController;
import com.weiyuwqj.api.common.PageList;
import com.weiyuwqj.api.common.Paginator;
import com.weiyuwqj.api.constant.Message;
import com.weiyuwqj.api.model.SysAssetCompany;
import com.weiyuwqj.api.service.SysAssetCompanyService;
import com.weiyuwqj.api.util.IpUtils;

/**
 * 
 * @className:SysAssetCompanyController	
 * @Description: 资产方controller
 * @author cx
 * @date:2017年3月25日上午11:27:40 
 *
 */
@RestController
@RequestMapping(value = "/admin/assetCompany")
public class SysAssetCompanyController extends BaseController{
	
	@Autowired
	private SysAssetCompanyService sysAssetCompanyService;
	
	/**
	 * 列表分页
	 * @param name
	 * @return
	 */
	@RequestMapping(value ="/getPageList",method = RequestMethod.POST)
	public PageList getPageList(final Paginator p,final String name){
		return this.sysAssetCompanyService.getList(p,name);
	}
	
	/**
	 * 列表
	 * @return
	 */
	@RequestMapping(value ="/getList",method = RequestMethod.POST)
	public List<HashMap<String,Object>> getList(){
		 return this.sysAssetCompanyService.getList();
	}
	
	/**
	 * 根据id查询
	 * @param id
	 * @return
	 */
	@RequestMapping(value ="/findById",method = RequestMethod.POST)
	public SysAssetCompany findById(final Integer id){
		return this.sysAssetCompanyService.findById(id);
	}
	
	/**
	 * 保存
	 * @param assetCompany
	 * @return
	 */
	@RequestMapping(value ="/save",method = RequestMethod.POST)
	public HashMap<String,String> save(final SysAssetCompany assetCompany){
		assetCompany.setCreator(getSessionUserId());
		assetCompany.setAddip(IpUtils.get());
		assetCompany.setAddtime(new Date());
		if(assetCompany.getId()!=null && assetCompany.getId()>0){
			this.sysAssetCompanyService.updateNotNull(assetCompany);
		}else{
			this.sysAssetCompanyService.save(assetCompany);
		}
		return Message.OK;
	} 
}
